import requests

# 定义参数
base_url = "https://httpbin.org"
user = "testuser"
passwd = "testpass"
qop = "auth" # 或者auth-int

# 构造请求 URL
url = f"{base_url}/digest-auth/{qop}/{user}/{passwd}"

# 使用 Digest Authentication
response = requests.get(url, auth=requests.auth.HTTPDigestAuth(user, passwd))

# 输出结果
if response.status_code == 200:
    print("Authentication successful!")
    print(response.json())  # 输出返回的 JSON 数据
else:
    print(f"Authentication failed! Status code: {response.status_code}")